|
|
|
|
|
|
|
' open existing file
Open strFileName For Append As intFileHandle
'
End Sub
Private Sub WriteHeader()
'
' send out standard header
'
Print #intFileHandle, String(60, "*")
Print #intFileHandle, strHeader
Print #intFileHandle, "Created: " & Format(Now(), "general date")
Print #intFileHandle, String(60, "*")
Print #intFileHandle, ""
'
End Sub |
|
|
|
|
|
|
|
|
Notice that the OpenLogFile method first checks to see whether the file exists. If it does not, a new one is created and a log header is written to the new file. |
|
|
|
|
|
|
|
|
Now add the final routine, ClearLog. This one allows you to clear an existing log file and start out fresh. Add the code from Listing 21.39 to your class module. |
|
|
|
|
|
|
|
|
Listing 21.39. Coding the ClearLog method. |
|
|
|
|
|
|
|
|
Public Sub ClearLog()
'
' clear all records from the log
'
On Error GoTo LocalErr
'
Dim intFile As Integer
'
intFile = FreeFile
'
Open strFileName For Output As intFile
WriteHeader
Close #intFile
'
Exit Sub
'
LocalErr:
Err.Raise Err.Number, App.EXEName & ".logObject", Err.Description
'
End Sub |
|
|
|
|
|
|
|
|
Now save the DLL project again. You have created all the routines you need in order to add detailed audit trails to any Visual Basic project. This is the last of the modifications to the prjUsrObject DLL library. But before going on to the next section, let's make a final modification to the test project to verify that the audit routines are working. |
|
|
|
|
|